#include <QApplication>
#include <QDateTime>
#include <QDebug>
#include <QProcess>
#include <QJsonDocument>
#include <QJsonObject>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QProcess process;
    process.start("docker", QStringList() << "images" << "--format" << "{{json .}}");
    process.waitForFinished();
    while (process.canReadLine()) {
        QString line = process.readLine();
        QJsonDocument doc = QJsonDocument::fromJson(line.toUtf8());
        if (!doc.isObject()) {
            continue;
        }
        
        QJsonObject obj = doc.object();
        auto Containers = obj.value("Containers").toString();
        auto CreatedAt = obj.value("CreatedAt").toString();
        auto CreatedSince = obj.value("CreatedSince").toString();
        auto Digest = obj.value("Digest").toString();
        auto ID = obj.value("ID").toString();
        auto Repository = obj.value("Repository").toString();
        auto SharedSize = obj.value("SharedSize").toString();
        auto Size = obj.value("Size").toString();
        auto Tag = obj.value("Tag").toString();
        auto UniqueSize = obj.value("UniqueSize").toString();
        auto VirtualSize = obj.value("VirtualSize").toString();

        qDebug() << Repository << Tag << Size;
    }

    return 0;
}

/**
{
    "Containers": "N/A",
    "CreatedAt": "2025-04-30 21:08:19 +0800 CST",
    "CreatedSince": "3 weeks ago",
    "Digest": "<none>",
    "ID": "ed331f9d3352",
    "Repository": "jenkins/jenkins",
    "SharedSize": "N/A",
    "Size": "466MB",
    "Tag": "lts",
    "UniqueSize": "N/A",
    "VirtualSize": "465.7MB"
}
 */